import 'package:flutter/material.dart';
import 'package:get/get.dart';

class OrderStatus {
  final IconData icon;
  final String label;
  const OrderStatus(this.icon, this.label);
}

const List<OrderStatus> _statuses = [
  OrderStatus(Icons.account_balance_wallet, '待付款'),
  OrderStatus(Icons.local_shipping, '待发货'),
  OrderStatus(Icons.receipt_long, '待收货'),
  OrderStatus(Icons.rate_review, '待评价'),
  OrderStatus(Icons.headset_mic, '售后'),
];

class OrderStatusItem extends StatelessWidget {
  final OrderStatus status;
  const OrderStatusItem({Key? key, required this.status}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Column(
      mainAxisSize: MainAxisSize.min,
      children: [
        Icon(status.icon, size: 28, color: Colors.grey[600]),
        const SizedBox(height: 6),
        Text(
          status.label,
          style: TextStyle(fontSize: 12, color: Colors.grey[800]),
        ),
      ],
    );
  }
}

class OrderStatusBar extends StatelessWidget {
  const OrderStatusBar({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Row(
      children: _statuses
          .map((s) => Expanded(
                  child: GestureDetector(
                onTap: () {
                  Get.toNamed('/order_list', arguments: {'status': s.label});
                },
                child: OrderStatusItem(status: s),
              )))
          .toList(),
    );
  }
}
